<?php
/**
 * 后台菜单(权限控制节点)模块
 * 
 */

class VideoAction extends AdminAction {
	public function _initialize() {
		parent::_initialize();	//RBAC 验证接口初始化
		Vendor('Common.Tree');	//导入通用树型类
	}
	
	
	private $root_name="";
	private $site_root='';
	private $howto_no_statice_name = 'howto_no_statice_name';
    private $plate_no_statice_name = 'plate_no_statice_name';
	private $statice_fail = 'staice_fail';
	private $statice_success = 'statice_success';
	private $delete_success = 'delete_success';
    private $delete_fail = 'delete_fail';
	private $file_noexist = 'file_noexist';
	private $dele_statice_success = 'dele_statice_success';
	private $pro_no_statice_name = 'pro_no_statice_name';
	
	
	public function __construct(){
    	$this->root_name = 'http://'.$_SERVER['HTTP_HOST'].'/index.php';
    	$this->site_root = 'http://'.$_SERVER['HTTP_HOST'];
    	parent::__construct();

    }
	
	 //视频下载email信息
    public function product_download_email(){
    	

    	$dy = M('email');
    	$where = ' 1=1 ';
    	if(!empty($_POST['t_time']) && !empty($_POST['e_time'])){
    		$where .= " and think_email.time >= '".$_POST['t_time']."' and think_email.time <= '".$_POST['e_time']."' ";
    	}else{
    		$where .= " and think_email.time = '".date('Y-m-d')."' ";
    	}
    	$this->assign('s_time',$_POST['t_time']);
    	$this->assign('e_time',$_POST['e_time']);
    	if(!empty($_POST['plate'])){
    		$cid = $_POST['plate'];

    		$this->assign('b_id',$cid);

    	}
    	$pdata = $dy->field('think_email.*')->where($where)->select();
    	$this->assign('product',$pdata);
    	$this->display();

    }

    

  
    
     
//添加视频信息
     public function dcamera()
    {
   		
		if($this->isPost()){
			$data['title']=isset($_POST['title'])?trim($_POST['title']):'';
			$data['des']=isset($_POST['des'])?trim($_POST['des']):'';
			$data['download_link']=isset($_POST['download_link'])?trim($_POST['download_link']):'';
			$data['img_addr']=isset($_POST['img_addr'])?trim($_POST['img_addr']):'';
			$data['video_addr']=isset($_POST['video_addr'])?trim($_POST['video_addr']):'';
			$data['version']=isset($_POST['version'])?trim($_POST['deversion']):'';
			$data['author']=isset($_POST['author'])?trim($_POST['author']):'';
			$data['sort']=isset($_POST['sort'])?trim($_POST['sort']):'';
			$data['sub_date'] = date('Y-m-d');

			if(!$data['download_link'] || !$data['img_addr'] || !$data['video_addr'])
			{
				exit('下载链接或图链接或视频链接不能为空');
			}
		$ht = M('camera');
		if($ht->where("title='".$data['title']."' or download_link='".$data['download_link']."'")->find()){
    			echo "<script>alert('标题名已存在，请填写其他标签名 或下载地址已存在');history.back();</script>";

    			return;
    		}
    		if($ht->add($data)){
    			echo "<script>alert('添加成功');location.href='".__URL__."/dcamera';</script>";
    		}else{
    			echo "<script>alert('添加失败');history.back();</script>";
    		}

    	}else{
    		$this->display();
    	}
    }

    //视频信息管理
    public function camera_classify_manage(){
    	
    	$classify=M('camera');
    	$cate=$classify->field('id,title')->select();
    	$this->assign('cate',$cate);
    	$this->display();
    }
	
	 //更改文章分类名称
     public function modify_camera_classify(){
    
     	if($this->isPost()){
			$system=M('camera');
    		$isset=isset($_POST['video_addr'])?$_POST['video_addr']:0;
    		$id = $_POST['id'];
    		if(!$isset){
    			return;
    		}
    		if($system->where("id=".$id)->save($_POST)){
    			echo "<script>alert('修改成功');history.back();</script>";
    		}else{
    			echo "<script>alert('修改失败');history.back();</script>";
    		}

    	}else{
    		$s=M("camera");
    		$id=$_GET['id'];
    		$data=$s->where("id=".$id)->find();
    		$this->assign('camera',$data);
    		$this->display();
    	}
     }
     //删除文章分类
    public function delete_camera_classify(){
    	header("Content-Type:text/html; charset=utf-8");
     	$id=$_GET['id'];
      	if (!$id){
     		return;
     	}
     	$camera_classify=M('camera');
     	$ret=$camera_classify->where("id=$id")->delete();
    	if(!$ret){
			echo $this->delete_fail;
			return;
     	}else{
			echo $this->delete_success;
     	}
     }

	
}